package com.ksd.system.service.impl;

import java.util.List;

import com.ksd.common.constant.UserConstants;
import com.ksd.common.utils.DateUtils;
import com.ksd.common.utils.StringUtils;
import com.ksd.system.domain.SysFirst;
import com.ksd.system.service.ISysFirstService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ksd.system.mapper.SysBoardMapper;
import com.ksd.system.domain.SysBoard;
import com.ksd.system.service.ISysBoardService;

/**
 * 板卡配置Service业务层处理
 * 
 * @author y.wu
 * @date 2025-02-11
 */
@Service
public class SysBoardServiceImpl implements ISysBoardService 
{
    @Autowired
    private SysBoardMapper sysBoardMapper;

    /**
     * 查询板卡配置
     * 
     * @param id 板卡配置主键
     * @return 板卡配置
     */
    @Override
    public SysBoard selectSysBoardById(Long id)
    {
        return sysBoardMapper.selectSysBoardById(id);
    }

    /**
     * 查询板卡配置列表
     * 
     * @param sysBoard 板卡配置
     * @return 板卡配置
     */
    @Override
    public List<SysBoard> selectSysBoardList(SysBoard sysBoard)
    {
        return sysBoardMapper.selectSysBoardList(sysBoard);
    }

    /**
     * 新增板卡配置
     * 
     * @param sysBoard 板卡配置
     * @return 结果
     */
    @Override
    public int insertSysBoard(SysBoard sysBoard)
    {
        sysBoard.setCreateTime(DateUtils.getNowDate());
        return sysBoardMapper.insertSysBoard(sysBoard);
    }

    /**
     * 修改板卡配置
     * 
     * @param sysBoard 板卡配置
     * @return 结果
     */
    @Override
    public int updateSysBoard(SysBoard sysBoard)
    {
        return sysBoardMapper.updateSysBoard(sysBoard);
    }

    /**
     * 批量删除板卡配置
     * 
     * @param ids 需要删除的板卡配置主键
     * @return 结果
     */
    @Override
    public int deleteSysBoardByIds(Long[] ids)
    {
        return sysBoardMapper.deleteSysBoardByIds(ids);
    }

    /**
     * 删除板卡配置信息
     * 
     * @param id 板卡配置主键
     * @return 结果
     */
    @Override
    public int deleteSysBoardById(Long id)
    {
        return sysBoardMapper.deleteSysBoardById(id);
    }

    @Override
    public boolean checkUrlUnique(SysBoard sysBoard) {
        Long id = StringUtils.isNull(sysBoard.getId()) ? -1L : sysBoard.getId();
        SysBoard info = sysBoardMapper.checkUrlUnique(sysBoard.getUrl());
        if (StringUtils.isNotNull(info) && info.getId().longValue() != id.longValue())
        {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }
}
